package com.jxl.domain.service.impl;


import com.jxl.common.enums.DeletedCodeEnum;
import com.jxl.domain.convert.AuthRoleBOConvert;
import com.jxl.domain.entity.AuthRoleBO;
import com.jxl.domain.service.AuthRoleDomainService;
import com.jxl.infra.basic.entity.AuthRole;
import com.jxl.infra.basic.service.AuthRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {

    @Resource
    private AuthRoleService authRoleService;

    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole =
                AuthRoleBOConvert.INSTANCE.convertBOToAuthRole(authRoleBO);
        int insert = authRoleService.insert(authRole);
        return insert>0;
    }

    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole =
                AuthRoleBOConvert.INSTANCE.convertBOToAuthRole(authRoleBO);
        int update = authRoleService.update(authRole);
        return update>0;
    }

    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole =
                AuthRoleBOConvert.INSTANCE.convertBOToAuthRole(authRoleBO);
        authRole.setIsDeleted(DeletedCodeEnum.DELETE.getCode());
        int delete = authRoleService.update(authRole);
        return delete>0;
    }
}
